package com.xiao.exampleconsumer1;

import com.xiao.example.common.model.User;
import com.xiao.example.common.service.UserService;
import com.xiao.rpc.proxy.ServiceProxyFactory;

/**
 * 简易服务消费者示例
 *
 */
public class EasyConsumerExample {

    public static void main(String[] args) {
        // 静态代理
//        UserService userService = new UserServiceProxy();
        // JDK动态代理  得到UserService的实现类
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
        User user = new User();
        user.setName("xiaoyu");
        // 【调用】  仅仅是需要一行代码，即可完成调用，而不是写多行HTTP请求
        User newUser = userService.getUser(user);
        if (newUser != null) {
            System.out.println(newUser.getName());
        } else {
            System.out.println("user == null");
        }
    }
}
